const express = require('express')
const router = express.Router()
const userAuth = require('../middlewares/user-auth');
const { success, failure } = require('../utils/responses')

const {generatePay} =require('../services/payService')

const generatePay1 = async (req, res) => {

    console.log(req.body,req.userId)
    try {
      const data = await getOrder({
        outTradeNo: req.body.outTradeNo,
        userId: req.userId
      })
      
      success(res, '支付地址获取成功。', data)
    } catch (error) {
      failure(res, error, '支付地址获取失败：')
    }
  }

/**
 * 生成支付链接
 * POST /pay
 */
router.post('/', userAuth, generatePay)

// /**
//  * 同步通知
//  * GET /pay/finish
//  */
// router.get('/finish', payController.finishSync)

// /**
//  * 异步通知
//  * GET /pay/notify
//  */
// router.get('/notify', payController.notifyAsync)

// /**
//  * 主动查询ezf订单状态
//  * GET /pay/query
//  */
// router.get('/query', userAuth, payController.queryPayOrder)

// /**
//  * 主动更新ezf订单状态
//  * GET /pay/update
//  */
// router.get('/update', userAuth, payController.updatePayOrder)

module.exports = router; 
